using System;

namespace FridgeCase
{
    public class Fridger
    {
        private readonly int _number;
        public bool[,] FridgeField;

        public Fridger():this(4)
        {
        
        }
        
        public Fridger(int n)
        {
            _number = n;
            FridgeField = new bool[_number, _number];
            Clear();
        }
        public Fridger Clone()
        {
            var temp = new Fridger();
            for (var i = 0; i < _number; i++)
                for (var j = 0; j < _number; j++)
                    temp.FridgeField[i, j] = FridgeField[i, j];
            return temp;
        }
        public void Clear()
        {
            for (var i = 0; i < _number; i++)
                for (var j = 0; j < _number; j++)
                    FridgeField[i, j] = true;
        }
        public void Change(int x, int y)
        {
            if (x >= _number || x < 0 || y >= _number || y < 0)
            {
                throw new ArgumentOutOfRangeException();
            }
            for (var i = 0; i < _number; i++)
            {
                FridgeField[x, i] = !FridgeField[x, i];
                FridgeField[i, y] = !FridgeField[i, y];
            }
            FridgeField[x, y] = !FridgeField[x, y];
        }

        public bool[,] GetPole()
        {
            return FridgeField;
        }
        private bool Test()
        {
            var check = true;
            for (var i = 0; i < _number; i++)
            {
                for (var j = 0; j < _number; j++)
                    if (FridgeField[i, j] == false) 
                        check = false;
                if (!check) break;
            }
            return check;
        }
        public string Help()
        {
            return Helper(0, Clone(), 4);
        }
        private string Helper(int count, Fridger temp, int n)
        {
            var result = string.Empty;
            for (var i = 0; i < 4; i++)
                for (var j = 0; j < 4; j++)
                {
                    temp.Change(i, j);
                    if (n < count)
                        return string.Empty;
                    if (temp.Test())
                        return " " + i + "-" + j;
                    var tmp = Helper(count + 1, temp.Clone(), n);
                    if (tmp.Length > 0)
                       result = tmp + " " + i + "-" + j ;
                    temp.Change(i, j);
                }
            return result;
        }
    }
}